package mathcad;

import static java.lang.Math.*;

public class Polyn {

    public double a, b, c;
    private Polyn[] polynomes;
    private final static double s3 = sqrt(3);

    public Polyn() {
        polynomes = new Polyn[ 8 ];
        int k = 0;
        for (int r0 = 1 ; r0 <= 2 ; r0++) {
            for (int r1 = 1 ; r1 <= 2 ; r1++) {
                for (int r2 = 1 ; r2 <= 2 ; r2++) {
                    polynomes[k++] = new Polyn(r0, r1, r2);

                }
            }
        }

    }

    public Polyn(int r0, int r1, int r2) {
        double u = p2(r0);
        double v = p2(r1 / 2);
        double w = p2(r2 / 2);
        double denom = (-w + v) * (-u + v) * (w - u);
        System.out.println(denom);
//        assert denom!=0;
        if (denom != 0) {
            a = s3 * (v - 2 * u + w) / denom;
            b = -s3 * (p2(v) + p2(w) - 2 * p2(u)) / denom;
            c = s3 * (-u * v - w * u + p2(v) + p2(w)) / denom;
        }
    }

    public Polyn[] getPolynomes() {
        return polynomes;
    }

    private double p2(double r) {
        return pow(r, 2);
    }
}














